#include<bits/stdc++.h>
using namespace std;
const int N=2e5;
stack<int> s[2];
bool c[N+1];
int q,n;
int a[N+1],l0=-1,l1=-1,ans;
void print()
{

    for(int i=1;i=n;i++) if(c[i]==1) cout<<a[i]<<" ";
    cout<<"\n";
    for(int i=1;i=n;i++) if(c[i]==0) cout<<a[i]<<" ";
    cout<<"\n";

}
void walk(int dep)
{
    if(dep>n)
    {
        /*for(int i=1;i<=n;i++) cout<<c[i]<<" ";
        cout<<"\n";
        for(int i=1;i<=n;i++) if(!c[i]) cout<<a[i]<<" ";
        cout<<"\n";
        for(int i=1;i<=n;i++) if(c[i]) cout<<a[i]<<" ";
        cout<<"\n";*/
        l1=-1;
        l0=-1;
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            if(c[i])
            {
                if(l1!=a[i]) l1=a[i];
                else sum+=a[i];
            }
            else
            {
                if(l0!=a[i]) l0=a[i];
                else sum+=a[i];
            }
        }
        ans=max(sum,ans);
        //cout<<sum<<"\n";
        return ;
    }
    c[dep]=1;
    walk(dep+1);
    c[dep]=0;
    walk(dep+1);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>q;
    while(q--)
    {
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        ans=0;
        walk(1);
        cout<<ans<<"\n";
    }

    return 0;
}
